﻿<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');

?>
<?php 
	$url = $this->baseurl.'/images/com_retailshop/';	
	$caregory = '';
	/*for($i = 0 ; $i < count($this->catagorys_Menu); $i++){
		if($i!=3)
			$caregory .= '<li><a href="index.php?option=com_retailshop&view=home&task=detailscatelog&id='.$this->catagorys_Menu[$i]->id.'">'.$this->catagorys_Menu[$i]->name.'</a></li>';
		else{
			$caregory .= '<li class="last"><a href="index.php?option=com_retailshop&view=home&task=detailscatelog&id='.$this->catagorys_Menu[$i]->id.'">'.$this->catagorys_Menu[$i]->name.'</a></li>';
			break;
		}
	}*/
?>	
    <div class="wrapper wpmain">
		<div id="main-premium">
			<div class="find">
				<h4>Find the local Areashop</h4>
				<div id="findlocalshop" class="blockwhite">
					<form class="select_form" action="" method="post" id="adminForm">
							<div class="element">
								<label>Category</label>
								<select class="select" id="category_select">
									<option value="-1"> --- Please Select Category --- </option>
									<?php foreach($this->catagorys as $c) { ?>
									<option value="<?php echo $c->id?>"><?php echo $c-> name; ?></option>          
									<?php } ?>                      
								</select>
							</div>
							<div class="element">
								<label>Country</label>
								<select class="select" id="country_select">
									<option value="-1"> --- Please Select Country --- </option>
								<?php foreach($this->countrys as $c) { ?>
									<option value="<?php echo $c->id ?>"><?php echo $c-> name; ?></option>          
								<?php } ?>
								</select>
							</div>
							<div class="element">
								<label>State</label>
								<select class="select" id="city_select">
									<option value="-1"> --- Please Select State --- </option>                    
								</select>
							</div>
							<div class="element">
								<label>City name</label>
								<input type="text" placeholder="" name="txt" id="find_cityname">					
							</div>
							<div class="element">
								<label>Brand</label>
								<input type="text" placeholder="EX: Brand one; Brand tow; ..." name="txt" id="brand_select">					
							</div>
							<button type="button" id="startretailshop">Find</button>
					</form>
					<div class="list_result" id="list_result">
						
					</div>
				</div>
			</div>
		</div>
        
        <div id="main-search">
				<?php echo $this->loadTemplate('left');?>		                        
			</div>
	
		<div id="main-search" style="display: none;">
             <div id="category-block" class="block">
              	<h4>Category</h4>
                <div class="block-content">
                	<ul>
						<?php if($this->catagorys ==null){ ?>
						<li class="no-category">NO CATEGORY</li>
						<?php }else{ ?>
						<?php foreach($this->catagorys as $c){ ?>
						<li><a a href="index.php?option=com_retailshop&view=home&task=detailscatelog&id=<?echo $c->id;?>"><?php echo $c->name; ?></a></li>
						<?php }} ?>
                    </ul>
                </div>
             </div>             
			<div id="aboutus" class="block">
              		<h4>About us</h4>
                    <div class="text">
                        <h2>Retailshop.info</h2>
                        <p>Best place to find out on going activities happening right there at local retail shop.</p>
            			<p>For Example : Despite of, a coffee shop which I can see from my office ,going to that place I will track it from my office  and will order him or grab  the coupon also.</p>
                        <a href="#">Read more</a>
                    </div>
            </div>
		</div>
		
    </div>
	  
    
	
<script type="text/javascript">
	$(document).ready(function(){
		<?php if(isset($_GET['country'])&&isset($_GET['city'])&&isset($_GET['category'])&&isset($_GET['brand'])) { ?>
			var country_select =  '<?php  echo  $_GET['country']; ?>';
			var category_select =  '<?php  echo $_GET['city']; ?>';
			var city_select =  '<?php echo  $_GET['category']; ?>';
			var brand_select =  '<?php echo  $_GET['brand']; ?>';
			
			if(country_select != -1 || category_select != -1 || city_select!= -1 || brand_select != '')
			{
				$.ajax({
				 url:"index.php?option=com_retailshop&view=home&task=search",
				 data:{country_select:country_select, category_select:category_select, city_select:city_select, brand_select:brand_select},
				 type: "POST",
				 dataType: "html",
				 success:function(data) {
					if(data == -1) {
						alert("errors in processing");
					}else   {
						$("#list_result").html(data);
					}
				}
				});
			}
		<?php } ?>			
	});
</script>

<script type="text/javascript">
    $(window).load(function() {
		$('#sub-nav ul').html('<?php echo $caregory; ?>');
    });
    </script>